<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>档案管理</title>
<!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
<script src="libs/jquery-1.12.1.min.js"></script>
<link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script src="libs/handlebars.min.js"></script>
<script src="libs/jquery.backstretch.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="page-header">
				<h2>
					<strong>档案管理</strong>
				</h2>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="col-md-8">
			<ul class="nav nav-pills">
				<li class="active"><a href="#">首页</a></li>
				<li><a href="add.html">新加档案</a></li>
				<li><a href="tongji.html">统计</a></li>
				<li><a href="queryall.html">查询</a></li>
				<li><a href="#">用户：<span id="nickname"></span></a></li>
				<input className="form-control" id="search-box-value"
					placeholder="档案号或身份证号" type="text" />
				<span className="input-group-btn">
					<button id="search" type="button">
						<i className="fa fa-search"></i> 查询
					</button>
				</span>
				<button id="tuichu">用户退出</button>
			</ul>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-primary">
					<div class="panel-heading">
						<p>最近添加的四份档案</p>
					</div>
					<div class="panel-body" id="list1"></div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-primary">
					<div class="panel-heading">
						<p>最近浏览的四份档案</p>
					</div>
					<div class="panel-body" id="list2"></div>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	$(function() {
		$.getJSON('queryUsers.action', function(res) {
			$('#nickname').text(res.nickname);
		})
		$('#tuichu').click(function() {
			$.post('tuichu.action', function(res, status) {
				if ('OK' == res) {
					alert('退出成功');
					window.location.href = 'login.html'
				}
			});
		});
		$.backstretch("image/2.jpg");

		$.getJSON('queryjin.action', function(res) {
			console.log(res);
			var data = {
				'item' : res
			};
			var t = Handlebars.compile($('#template').html());
			$('#list1').html(t(data));
		})

		$.getJSON('queryliu.action', function(res) {
			console.log(res);
			var data = {
				'item1' : res
			};
			var t = Handlebars.compile($('#template').html());
			$('#list2').html(t(data));
		})

		$('#search').click(function() {
			$.post('queryone.action', {
				search : $('#search-box-value').val()
			}, function(res, status) {
				console.log(res);
				if ("ERR" == res) {
					alert('未查到档案');
				} else if ("ERR2" == res) {
					alert('错误')
				} else {
					alert('查到');
					window.location.href = 'query.html?id=' + res;
				}
			})
		})
	})
</script>
<script type="text/x-handlebars-template" id="template">
    {{#each item}}
    <div class="panel panel-default col-md-3">
      <div class="panel-body">
        <dl>
          <dt>档案号</dt> <dd>{{archive_id}}</dd>
          <dt>身份证号</dt> <dd>{{identity}}</dd>
          <dt>姓名</dt> <dd>{{name}}</dd>
          <dt>性别</dt> <dd>{{gender}}</dd>
          <dt>生日</dt> <dd>{{brithday}}</dd>
          <dt>预退休日期</dt> <dd>{{date_retire1}}</dd>
          <dt>实际退休日期</dt> <dd>{{date_retire2}}</dd>
          <dt>特殊工种</dt> <dd>{{sp}}</dd>
          <dt>女管理岗位</dt> <dd>{{fc}}</dd>
          <dt>职称</dt> <dd>{{title}}</dd>
          <dt>工龄</dt> <dd>{{seniority}}</dd>
       </dl>
     </div>
   </div>
   {{/each}}
    {{#each item1}}
    <div class="panel panel-default col-md-3">
      <div class="panel-body">
        <dl>
          <dt>档案号</dt> <dd>{{archive_id}}</dd>
          <dt>身份证号</dt> <dd>{{identity}}</dd>
          <dt>姓名</dt> <dd>{{name}}</dd>
          <dt>性别</dt> <dd>{{gender}}</dd>
          <dt>生日</dt> <dd>{{brithday}}</dd>
          <dt>预退休日期</dt> <dd>{{date_retire1}}</dd>
          <dt>实际退休日期</dt> <dd>{{date_retire2}}</dd>
          <dt>特殊工种</dt> <dd>{{sp}}</dd>
          <dt>女管理岗位</dt> <dd>{{fc}}</dd>
          <dt>职称</dt> <dd>{{title}}</dd>
          <dt>工龄</dt> <dd>{{seniority}}</dd>
       </dl>
     </div>
   </div>
   {{/each}}
 </script>
</html>